package com.artezio.buyndrive.validator;

import com.artezio.buyndrive.domain.Users;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.artezio.buyndrive.service.UserService;

/**
 *
 * @author vgordievich
 */
@Component
public class UserValidator implements Validator {

    @Autowired
    private UserService userService;

    @Override
    public boolean supports(Class<?> clazz) {
        return Users.class.isAssignableFrom(clazz);
    }

    @Override
    public void validate(Object target, Errors errors) {
        Users users = (Users) target;

        /*if (userService.login(users.getEmail(),
                users.getPassword()) == null) {

            errors.rejectValue("email", "email.error");
        }*/
    }
}